//
//  LGNavigationController.m
//  lgdw
//
//  Created by mac on 16/1/13.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "LGNavigationController.h"
#import "LGwebViewController.h"


/** tab的子控制器个数 */
#define TABBARCOUNT 4

@interface LGNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation LGNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    //    1> 获取系统自带滑动手势的target对象
    id target = self.interactivePopGestureRecognizer.delegate;
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wundeclared-selector"
    //    2> 创建全屏滑动手势，调用系统自带滑动手势的target的action方法
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
#pragma clang diagnostic pop
    
    //    4> 给导航控制器的view添加全屏滑动手势
    [self.view addGestureRecognizer:pan];
    //    5> 禁止使用系统自带的滑动手势
    self.interactivePopGestureRecognizer.enabled = NO;
    
    // 导航条渲染颜色
    self.navigationBar.tintColor = [UIColor whiteColor];
    
   // 背景颜色
    self.navigationBar.barTintColor = [UIColor blackColor];
    // 字体颜色
    self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if (self.childViewControllers.count == 1) {
        return NO;
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    static int checkKey = 1;
    // 隐藏tabBar
    if (checkKey > TABBARCOUNT) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
    checkKey++;
}

// 设置任务栏为白色
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}


@end
